package setting

import "time"

// SettingsS 所有配置
type SettingsS struct {
	Server   *ServerSettingS  `mapstructure:"server"`
	App      *AppSettingS     `mapstructure:"app"`
	Database *DBSettingsS     `mapstructure:"database"`
	Redis    *RedisSettingsS  `mapstructure:"redis"`
	AliOss   *AliOssSettingsS `mapstructure:"ali_oss"`
	JWT      *JWTSettingS     `mapstructure:"jwt"`
}

// ServerSettingS 服务的基础配置
type ServerSettingS struct {
	RunMode      string        `mapstructure:"run_mode"`
	HttpHost     string        `mapstructure:"http_host"`
	HttpPort     string        `mapstructure:"http_port"`
	ReadTimeout  time.Duration `mapstructure:"read_timeout"`
	WriteTimeout time.Duration `mapstructure:"write_timeout"`
}

// AppSettingS 应用相关配置
type AppSettingS struct {
	DefaultPageSize      int      `mapstructure:"default_page_size"`
	MaxPageSize          int      `mapstructure:"max_page_size"`
	LogSavePath          string   `mapstructure:"log_save_path"`
	LogFileName          string   `mapstructure:"log_file_name"`
	LogFileExt           string   `mapstructure:"log_file_ext"`
	TimeFormat           string   `mapstructure:"time_format"`
	UploadSavePath       string   `mapstructure:"upload_save_path"`
	UploadServerUrl      string   `mapstructure:"upload_server_url"`
	UploadImageMaxSize   int      `mapstructure:"upload_image_maxsize"`
	UploadImageAllowExts []string `mapstructure:"upload_image_allowexts"`
}

// DBSettingsS 数据库配置
type DBSettingsS struct {
	Driver       string `mapstructure:"driver"`
	UserName     string `mapstructure:"username"`
	PassWord     string `mapstructure:"password"`
	Host         string `mapstructure:"host"`
	DB           string `mapstructure:"db"`
	Prefix       string `mapstructure:"prefix"`
	ShowSQL      bool   `mapstructure:"show_sql"`
	Charset      string `mapstructure:"charset"`
	ParseTime    bool   `mapstructure:"parse_time"`
	MaxIdleConns int    `mapstructure:"max_idle_conns"`
	MaxOpenConns int    `mapstructure:"max_open_conns"`
}

// RedisSettingsS redis的配置
type RedisSettingsS struct {
	Addr string `mapstructure:"addr"`
	Auth string `mapstructure:"auth"`
	DB   int    `mapstructure:"db"`
	//TODO 加入连接池配置
}

// AliOssSettingsS 阿里云oss配置
type AliOssSettingsS struct {
	Bucket          string `mapstructure:"bucket"`
	EndPoint        string `mapstructure:"end_point"`
	AccessKeyId     string `mapstructure:"access_key_id"`
	AccessKeySecret string `mapstructure:"access_key_secret"`
	Domain          string `mapstructure:"domain"`
}

type JWTSettingS struct {
	Secret string        `mapstructure:"secret"`
	Issuer string        `mapstructure:"issuer"`
	Expire time.Duration `mapstructure:"expire"`
}
